package xiaohongshu

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

type XhsAuthService struct {
	AppId     string
	AppSecret string
	Key       string
	Token     string
}

func NewXhsAuthService(appId string, appSecret string, key string, token string) *XhsAuthService {
	return &XhsAuthService{
		AppId:     appId,
		AppSecret: appSecret,
		Key:       key,
		Token:     token,
	}
}

// 初始化授权类
func XhsAuthServiceInit() *XhsAuthService {
	appId := ""
	appSecret := ""
	key := ""
	token := ""
	return NewXhsAuthService(appId, appSecret, key, token)
}

// GetAccessToken     // 获取服务商调用凭证 1 有效时间两个小时
// Author [yourname](https://github.com/yourname)
func (XhsAuthService *XhsAuthService) GetAccessToken(c *gin.Context) (data string, err error) {
	return data, nil
}

// GetPreAuthCode     // 获取授权码 2
// Author [yourname](https://github.com/yourname)
func (XhsAuthService *XhsAuthService) GetPreAuthCode(c *gin.Context) (data string, err error) {
	return data, nil
}

// GetTicket     服务商创建后，小红书会每隔 10 分钟以 POST 请求向 授权事件接收 URL 发送 ticket 消息。
// Author [yourname](https://github.com/yourname)
func (XhsAuthService *XhsAuthService) GetTicket(c *gin.Context) (data string, err error) {
	requestQueryParams := c.Request.URL.Query()
	requestBodyParams := c.Request.Body

	fmt.Println("requestQueryParams:", requestQueryParams)
	fmt.Println("requestBodyParams:", requestBodyParams)
	return data, nil
}

// Callback     授权回调
// Author [yourname](https://github.com/yourname)
func (XhsAuthService *XhsAuthService) Callback(c *gin.Context) (data string, err error) {
	return data, nil
}

// Authorization     引导授权
// Author [yourname](https://github.com/yourname)
func (XhsAuthService *XhsAuthService) Authorization(c *gin.Context) (data string, err error) {
	return data, nil
}
